<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title></title>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all"/>
    <style>
        .layui-form-item .layui-input-inline {
            width: 150px;
        }
        .layui-form-label {
            padding: 9px 5px;
            width: auto;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-tab layui-tab-brief site-demo-table" lay-filter="demoTitle">
        <ul class="layui-tab-title site-demo-title">
            <li><a href="/admin/noble/level">贵族等级</a></li>
            <li class="layui-this">贵族记录</li>
        </ul>
    </div>
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <form class="layui-form layui-col-space5" id="sbumitForm">
            <div class="layui-form-item">
                <div class="layui-input-inline layui-show-xs-block" style="width: 180px">
                    <select name="noble_id" lay-filter="noble_id">
                        <option value="">按等级搜索</option>
                        {foreach $nobles as $list}
                        <option value="{$list.id}">{$list.name}</option>
                        {/foreach}
                    </select>
                </div>
                <div class="layui-inline ">
                    <label class="layui-form-label">用户ID</label>
                    <div class="layui-input-inline">
                        <input type="text" name="id" placeholder="按用户ID搜索" autocomplete="off" class="layui-input"/>
                    </div>
                </div>
                <div class="layui-inline ">
                    <div class="layui-input-inline">
                        <div class="layui-btn" id="submit">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                        </div>
                    </div>
                </div>

            </div>
            </form>
        </div>

        <div class="layui-card-body">
            <table id="demo" lay-filter="test"></table>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script>
    nobles = <?php echo $nobles_json;?>;
    layui
        .config({
            base: "/layuiadmin/", //静态资源所在路径
        })
        .extend({
            index: "lib/index", //主入口模块
        })
        .use(["index", "user", "table", "laydate"], function () {
            $ = layui.jquery, form = layui.form, table = layui.table;
            $("#submit").click(function () {
                table.render(opTableObj());
            });

            form.on('select(noble_id)', function (data) {
                table.render(opTableObj());
            });

            table.render(opTableObj());
        });

    function opTableObj() {
        return  {
            elem: '#demo',
            id: '#demo',
            url: '/admin/noble/index?' + $("#sbumitForm").serialize(),
            defaultToolbar: [
                'filter','print',{title:'提示',layEvent: 'LAYTABLE_EXCEL',icon: 'layui-icon-table'},
            ],
            page: {
                curr: 1   //默认从第一页开始搜索
            },
            method: "get",
            //where: $("#sbumitForm").serialize(),
            limit: 20,
            limits: [20, 30, 50, 100, 200, 500],
            text: {
                none: '暂无相关数据！'//默认无数据
            },
            response: {
                statusName: 'code', //数据状态的字段名称，默认：code
                statusCode: 0,//成功的状态码，默认：0
                msgName: 'msg', //状态信息的字段名称，默认：msg
                countName: 'count', //数据总数的字段名称，默认：count
                dataName: 'list', //数据列表的字段名称，默认：data
            },
            cols: [[ //表头
                {field: 'account', title: '用户名', width: "30%", align: "center",}
                ,{field: 'noble_id', title: '贵族等级', width:"35%", align: "center",templet: function (item) {
                        if (!nobles[item.noble_id] || nobles[item.noble_id] == 'nobles[item.noble_id]') {
                            return '';
                        }
                        return nobles[item.noble_id];
                    }
                }
                ,{field: 'expiration', title: '到期时间', width: "35%", align: "center",}
            ]],
            done: function (res, curr, count) {
                res.list.forEach(function (item, index) {

                });
            },
        };
    }
</script>
</body>
</html>
